package com.nzy.mq.producer;

import com.nzy.mq.OrderSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

@Component
@EnableBinding(OrderSource.class)
public class MessageProducer {

    @Autowired
    private OrderSource orderSource;

    public void send(OrderMessage message){
        orderSource.output().send(MessageBuilder.withPayload(message).build());
    }
}
